package com.example.demo.controller.admin;

import com.example.demo.R.BanResult;
import com.example.demo.domin.Vo.UserVO;
import com.example.demo.domin.dto.PageDTO;
import com.example.demo.domin.dto.UserDTO;
import com.example.demo.domin.entity.User;
import com.example.demo.domin.query.UserQuery;
import com.example.demo.service.admin.IAdminService;
import com.example.demo.service.user.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/admin")
public class Admincontroller {
    @Autowired
    private IUserService userService;
    @Autowired
    private IAdminService adminService;

    @PostMapping("/login")
    public Map login(@RequestBody User user){
        return Map.of("token", UUID.randomUUID());
    }


    @GetMapping("/users")
    public PageDTO<UserVO> queryUsersPage(UserQuery query){
        return userService.queryUsersPage(query);
    }
    @PostMapping("/users/{user_id}/ban")
    public BanResult ban(@PathVariable("user_id") String id, @RequestBody UserDTO userDto){
        return adminService.ban(id,userDto);
    }
}
